
interface IFlying{
    void flying();
}

interface ISwimming{
    void swimming();
}

interface IRunning{
    void running();
}

/**
 * 接口的继承
 * A3接口拥有了ISwimming和IRunning两个接口的功能
 * 并且增加了自己的功能
 * 接口和接口之间用extends
 * 类和接口之间用implements
 */
interface A3 extends ISwimming,IRunning{
    void func();
}

class Animal{
    public String name;
    public int age;
    public Animal(){
        this.name = "xiao";
        this.age = 10;
    }

    public Animal(String name,int age){
            this.name = name;
            this.age = age;
    }
    public void eat(){
        System.out.println(name + "在吃饭");
    }
}

class Bird extends Animal implements IFlying{
    public Bird(String name,int age){
        super(name,age);
    }

    @Override
    public void flying() {
        System.out.println(super.name + "在天空翱翔");
    }
}

class Duck extends Animal implements IFlying,ISwimming,IRunning{
    public Duck(String name,int age){
        super(name,age);
    }

    @Override
    public void flying() {
        System.out.println(name + "在天空翱翔");
    }

    @Override
    public void swimming() {
        System.out.println(name + "在游泳");
    }

    @Override
    public void running() {
        System.out.println(name + "在跑");
    }
}

class Dog extends Animal implements ISwimming{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void swimming() {
        System.out.println(name + "在游泳");
    }
}

public class Test3 {

    public static void walk(IRunning iRunning){
        iRunning.running();
    }

    public static void swim(ISwimming iSwimming){
        iSwimming.swimming();
    }

    public static void main(String[] args) {
        Bird bird = new Bird("麻雀",5);
        Duck duck = new Duck("鸭子",7);
        walk(duck);
        swim(duck);
    }

}
